﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhSystemBLL.orderData;
using dhDataAcess.baseBLL;
using baseSet.importExport;
using dhsystem.produceForm.picking;

namespace dhsystem.produceForm.pdrk
{
    public partial class FrmpiaoranPlan : Form
    {
        public FrmpiaoranPlan()
        {
            InitializeComponent();
        }
        orderDetailBLL orderDetail = new orderDetailBLL();
        private void FrmpiaoranPlan_Load(object sender, EventArgs e)
        {
            //DataTable dt = new DataTable();
            //dt.Load(basicSql.getorderMasterlII());
            bindingSourceorderDetailNo.DataSource = basicSql.getorderDetail();
            dGridorderproduce.DataSource = bindingSourceorderDetailNo;
            DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderproduce);
            bgSourceorderDetailYes.DataSource = basicSql.getorderDetailII();
            dGridorderMaster.DataSource = bgSourceorderDetailYes;
            DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderMaster);
            this.tabControl1.SelectedIndex = 0;
         

        }

        private void 复色ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderproduce.CurrentRow.Cells["orderNo"].Value.ToString();
            Frmwritecolor wretecolor = new Frmwritecolor(orderNo,"复色");
            DialogResult result = wretecolor.ShowDialog();
            if (result == DialogResult.Yes)
            {
                bindingSourceorderDetailNo.DataSource = basicSql.getorderDetail();
                dGridorderproduce.DataSource = bindingSourceorderDetailNo;
                DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderproduce);
            }
        }

        private void toolExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void tabControl1_Selected(object sender, TabControlEventArgs e)
        {
            //已复色漂染单
            if (e.TabPage == tabPage1)
            {
                bgSourceorderDetailYes.DataSource = basicSql.getorderDetailII();
                dGridorderMaster.DataSource = bgSourceorderDetailYes;
                DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderMaster);
            }
            //未复色漂染单
            if (e.TabPage == tabPage2)
            {
                bindingSourceorderDetailNo.DataSource = basicSql.getorderDetail();
                dGridorderproduce.DataSource = bindingSourceorderDetailNo;
                DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderproduce);
            }
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            string orderNo = dGridorderMaster.CurrentRow.Cells["orderNo"].Value.ToString();
            string orderDetailNo = dGridorderMaster.CurrentRow.Cells["orderDetailNo"].Value.ToString();
            orderMasterBLL orderMaster = new orderMasterBLL();
            bindingSourorderMaster.DataSource = orderMaster.getorderMasterAllByorderNo(orderNo);

            FrmpdpqbAdd pdpqbAdd = new FrmpdpqbAdd("新增", bindingSourorderMaster, orderDetailNo,"");
            DialogResult result = pdpqbAdd.ShowDialog();
            if (result == DialogResult.Yes)
            {
                bgSourceorderDetailYes.DataSource = basicSql.getorderDetailII();
                dGridorderMaster.DataSource = bgSourceorderDetailYes;
                DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderMaster);
            }
        }

        private void buttonQuery_Click(object sender, EventArgs e)
        {
            bgSourceorderDetailYes.DataSource = basicSql.getorderDetailfuse("%" + textbillNoQuery.Text + "%");
            dGridorderMaster.DataSource = bgSourceorderDetailYes;
            DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderMaster);
        }

        private void tabPage2_Click(object sender, EventArgs e)
        {

        }

        private void button11_Click(object sender, EventArgs e)
        {
            bindingSourceorderDetailNo.DataSource = basicSql.getorderDetailNofuse("%" + textorderproduce.Text + "%");
            dGridorderMaster.DataSource = bindingSourceorderDetailNo;
            DcolumnSet.colSet(moduleInfo.orderDetail, dGridorderMaster);
        }

        private void button10_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.orderDetail, dGridorderproduce, "未复色单信息");
            frm.ShowDialog();
        }
    }
}
